<template>
	<view class="commondity" :style="'flex-wrap:'+ warp + ';'">
		<!-- 每个商品信息 -->
		<view class="commondity-item"
			v-for="(item,index) in dataList"
			:key="index"
			:style="'width:' + itemW + ';'"
			@tap="goDetails(item.id)"
		>
			<image
			 class="commondity-img"
			  :src="item.imgUrl"
			   mode=""
			:style="'height:' + bigH + ';'"
			   ></image>
			
			<view class="commondity-content">
				<text class="commondity-name">{{item.name}}</text>
				<view>
					<text class="pprice">{{item.pprice}}</text>
					<text class="oprice">{{item.oprice}}</text>
				</view>
			<text class="discount">{{item.discount}}折</text>
			</view>
		</view>
		
		<!-- <view class="commondity-item">
			<image class="commondity-img" src="../../static/img/1.webp" mode=""></image>
			
			<view class="commondity-content">
				<text class="commondity-name">sssssssssss</text>
				<view>
					<text class="pprice">$299</text>
					<text class="oprice">$659</text>
				</view>
			<text class="discount">5.2折</text>
			</view>
		</view> -->
		
	</view>
</template>

<script>
export default{
	props:{
		dataList:Array,
		itemW:{
			type:String,
			default:"375rpx"
		},
		bigH:{
			type:String,
			default:"375rpx"
		},
		warp:{
			type:String,
			default:"wrap"
		}
	},
	methods:{
		goDetails(id){
			uni.navigateTo({
				url:'/pages/details/details?id='+id
			})
		}
	}
}
</script>

<style scoped>
	.commondity{
		display: flex;
		
	}
	.commondity-item{
		width: 375rpx;
		padding-bottom: 20rpx;
	}
	.commondity-img{
		width: 100%;
		height: 375rpx;
	}
	.commondity-content{
		text-align: center;
	}
	.commondity-name{
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		color: #333333;
		word-break: break-all;
		padding: 6rpx 20rpx;
	}
	.oprice{
		text-decoration: line-through;
		font-size: 24rpx;
		color: #999999;
	}
	.discount{
		border-radius: 4rpx;
		border: 1px solid #ff3333;
		padding: 2rpx 10rpx;
		font-size: 20rpx;
		color: #ff3333;
	}
</style>